﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.API.Application.Command.Supplier;
using Traceability.App.Domain.Traceability;
using Traceability.App.ErrorCode;

namespace Traceability.App.API.Controllers
{
    /// <summary>
    /// 供应商控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupplierController : ControllerBase
    {
        private readonly IMediator mediator;

        public SupplierController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取供应商信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<SupplierModel>> GetSupplier([FromQuery]GetSupplierCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 设置供应商信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> CreateSupplier(CreateSupplierCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 设置供应商信息接口2
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> UpdSupplier(UpdSupplierCommand request)
        {
            return mediator.Send(request);
        }
    }
}
